<?php
/**
 * run [php install.php] to install this plugin
 */
$replace_files = [
    'autoload.php' => '../application/config/autoload.php',
    'CodeIgniter.php' => '../system/core/CodeIgniter.php',
    'Controller.php' => '../system/core/Controller.php',
    'DB_query_builder.php' => '../system/database/DB_query_builder.php',
    'autoload.php' => '../application/config/autoload.php',
];

$add_files = [
    'CiProfiling.php' => '../application/libraries/',
    'profiling.php' => '../application/config/',
];

foreach ($replace_files as $replace_file => $original_file) {
    if (!file_exists($original_file)) {
        die("File[$original_file] does not exists! Please check it!");
    }
    exec("cp -f $replace_file $original_file");
}

foreach ($add_files as $add_file => $path) {
    if (!is_dir($path)) {
        die("Directory[$path] does not exists! Please check it!");
    }
    exec("cp -f $add_file $path");
}
